Component({
    data: {
        
    },
    options: {
        addGlobalClass: true,
    },
    properties: {
        type: {
            type: String,
            value: ''
        },
        title: {
            type: String,
            value: ''
        },
        icon: {
            type: String,
            value: ''
        },
        duration: {
            type: Number,
            value: 1500
        },
        isLoading: {
            type: Boolean,
            value: false
        },
    },
    lifetimes: {
        created() {
            
        },
        attached() {
            
        },
        ready() {

        },
    },
    observers: {
        title(val) {
            let _this = this;
			if (val && !_this.data.isLoading) {
                const timer = setTimeout(() => {
                    _this.hide();
                    clearTimeout(timer);
                }, _this.data.duration);
            }
		},
    },
    methods: {
        hide(){
            this.setState({
                '$toast.title':'', 
                '$toast.icon':'',
                '$toast.image':'',
                '$toast.duration': 0,
                '$toast.mask': false,
                '$toast.isLoading': false,
            })
        }
    }
})